package cn.ad.server.web.filter;

import cn.ad.server.web.spring.service.actions.context.AdContext;
import cn.ad.server.domain.ad.Strategy;

import java.util.ArrayList;
import java.util.List;

/**
 * @author dongbin.yu
 * @from 2016-06-08
 * @since V1.0
 */
public class TargetMatcherChain implements MatcherChain {

	private List<TargetMatcher> targetMatcherList = new ArrayList<>();

	public boolean match(Strategy strategy, AdContext context) {

		for (TargetMatcher targetMatcher : targetMatcherList) {
			boolean isMatch = targetMatcher.match(strategy, context);
			if (!isMatch) {
				return false;
			}
		}
		return true;
	}

	public void setTargetMatcherList(List<TargetMatcher> targetMatcherList) {
		this.targetMatcherList = targetMatcherList;
	}

}
